<?php
session_start();
$userid=$_SESSION['userid'];
include ('mysqli_connect.php');

$user_id=$_GET['userid'];
$movie_id=$_GET['movieid'];

$sqlb="select * from user_mark_table where user_id='{$user_id}' and movie_id='{$movie_id}'";
$resb=mysqli_query($dbc,$sqlb);
$resultb=mysqli_fetch_array($resb);
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <title>影视管理 || 用户评论修改</title>
</head>
<body>
<h1 style="text-align: center"><strong>用户评论修改</strong></h1><br/><br/><br/>
<div style="padding: 10px 500px 10px;">
    <form  action="admin_mark_edit.php?userid=<?php echo $user_id; ?>&movieid=<?php echo $movie_id; ?>" method="POST" style="text-align: center" class="bs-example bs-example-form" role="form">
        <div id="login">
            <div class="input-group"><span class="input-group-addon">评论时间</span><input name="ntime" value="<?php echo $resultb['marking_time'] ;?>" type="text" placeholder="请输入修改的评论" class="form-control"></div><br/>
            <div class="input-group"><span class="input-group-addon">评论分数</span><input name="ngrade" value="<?php echo $resultb['user_marking'] ;?>" type="text" placeholder="请输入修改的评论分数" class="form-control"></div><br/>
            <div class="input-group"><span class="input-group-addon">评论内容</span><input name="ncontent" value="<?php echo $resultb['marking_content'] ;?>" type="text" placeholder="请输入修改的评论内容" class="form-control"></div><br/>
            <input type="submit" value="确认" class="btn btn-default">
            <input type="reset" value="重置" class="btn btn-default">
        </div>
    </form>
</div>

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST")
{

    $ntime= $_POST["ntime"];
    $ngrade= $_POST["ngrade"];
    $ncontent = $_POST["ncontent"];

    $sqla="update user_mark_table 
    set 
    marking_time='{$ntime}',
    user_marking='{$ngrade}',
    marking_content='{$ncontent}'
    where user_id='{$user_id}' and movie_id='{$movie_id}';";
    $resa=mysqli_query($dbc,$sqla);

    if($resa==1)
    {

        echo "<script>alert('修改成功！')</script>";
        echo "<script>window.location.href='admin_movie_info.php?id={$movie_id}'</script>";

    }
    else
    {
        echo "<script>alert('修改失败！请重新输入！');</script>";
        echo "<script>window.location.href='admin_mark_edit.php?movieid={$movie_id}&userid={$user_id}'</script>";
    }

}

?>
</body>
</html>
